package com.hww.mq.consumer;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @Author: youdao.hww
 * @Date: 4/16/24
 * @Desc:
 */
@Slf4j
@Component
@RocketMQMessageListener(topic = "Topic-user", selectorExpression = "user", consumerGroup = "Group-user-consumer-2")
public class UserMQListener2 implements RocketMQListener<MessageExt> {


    @Override
    public void onMessage(MessageExt message) {
        log.info("Group-user-consumer-2,接收到消息,topic:{},tag:{},msgId:{},keys:{},msg:{}",
                message.getTopic(), message.getTags(), message.getMsgId(), message.getKeys(), JSONObject.toJSONString(message));

    }
}
